<?php

class DefaultController extends Controller
{
	public function actionIndex()
	{
            $time = $_REQUEST['timestamp'];
            
            if(isset($_FILES['icon'])){
                $uploaddir = './uploads/images/icons/';
                $file_name_temp = $time.'-'. basename($_FILES['icon']['name']);
                $file_name = str_replace(' ','',$file_name_temp);
                $destination = $uploaddir .$file_name; 
                 
                if (move_uploaded_file($_FILES['icon']['tmp_name'], $destination)) { 
                  echo 'success';
                } else {
                    echo "error";
                }
            }
            
            if(isset($_FILES['thumb'])){
                $uploaddir = './uploads/images/thumbs/';
                $file_name_temp = $time.'-'. basename($_FILES['thumb']['name']);
                $file_name = str_replace(' ','',$file_name_temp);
                $destination = $uploaddir .$file_name; 
                 
                if (move_uploaded_file($_FILES['thumb']['tmp_name'], $destination)) { 
                  echo 'success';
                } else {
                    echo "error";
                }
            }
            
            if(isset($_FILES['logo'])){
                $uploaddir = './uploads/images/logos/';
                $file_name_temp = $time.'-'. basename($_FILES['logo']['name']);
                $file_name = str_replace(' ','',$file_name_temp);
                $destination = $uploaddir .$file_name; 
                 
                if (move_uploaded_file($_FILES['logo']['tmp_name'], $destination)) { 
                  echo 'success';
                } else {
                    echo "error";
                }
            }
            
            if(isset($_FILES['screenshot'])){
                $uploaddir = './uploads/images/screenshots/';
                $file_name_temp = $time.'-'. basename($_FILES['screenshot']['name']);
                $file_name = str_replace(' ','',$file_name_temp);
                $destination = $uploaddir .$file_name; 
                 
                if (move_uploaded_file($_FILES['screenshot']['tmp_name'], $destination)) { 
                  echo 'success';
                } else {
                    echo "error";
                }
            }
	}
}